<template>
<div>
    <basic-container>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>产品配置</el-breadcrumb-item> 
        <el-breadcrumb-item>测试工具</el-breadcrumb-item>
        <el-breadcrumb-item>书币变更</el-breadcrumb-item>
      </el-breadcrumb>
    </basic-container>
    <basic-container>
      <el-form ref="form" :model="form" label-width="80px" class="demo-form-inline">
        <el-form-item label="用户id">
          <el-input v-model="form.uid"></el-input>
        </el-form-item>
        <el-form-item label="书币">
          <el-input type="number" v-model="form.count"></el-input>
          <div style="color : red">如果书币为负数，则是减书币。每次最多加1万豆</div>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">保存</el-button>
        </el-form-item>
    </el-form>    
  </basic-container>
</div>
</template>
<script>
import { common } from "@/api/cat/httpRequest"; 
import { tools as baseURL } from "@/api/cat/baseUrls";
export default {
  data() {
    return {
      form: {},
    };
  },
  methods: {
     /** 变更 */
    async onSubmit() {
      if(this.form.count==undefined){
        this.$message.error("请输入书币")
        return;
      }
      if(this.form.count>10000){
        this.$message.error("书币不可大于1万")
        return;
      }
      if(this.form.uid==undefined){
        this.$message.error("请输入用户id")
        return;
      }

      let {data} = await common(baseURL.changeUser+'/'+this.form.uid, null, null, "GET");
      if (data == null || data.length==0) {
        this.user = {}
        this.$message.error("用户不存在")
        return;
      }

      let response = await common(baseURL.beansChange+'/'+this.form.uid+'/'+this.form.count+'/1',null, null, "GET");
    },
  },
};
</script>